use std::env;
use crate::router;
use super::hybrid;


#[allow(dead_code)]
pub(crate) async fn web() {
    // application
    let web_app_service = router::web::register().into_make_service();
    let app_address = env::var("APP_ADDRESS").unwrap();
    let app_address_parse = &app_address.as_str().parse().unwrap();
    axum::Server::bind(app_address_parse)
        .http2_enable_connect_protocol()
        .serve(web_app_service)
        .with_graceful_shutdown(super::signal::shutdown_signal())
        .await
        .unwrap();
}
#[allow(dead_code)]
pub(crate) async fn hybrid() {
    // web application
    let web_app_service = router::web::register().into_make_service();
    let app_address = env::var("APP_ADDRESS").unwrap();
    let app_address_parse = &app_address.as_str().parse().unwrap();
    let grpc_app_service = router::grpc::register().into_service();
    // hybird
    let hybird_make_service = hybrid::hybrid(web_app_service, grpc_app_service);
    // start server
    hyper::Server::bind(app_address_parse)
        .serve(hybird_make_service)
        .with_graceful_shutdown(super::signal::shutdown_signal())
        .await
        .unwrap();
}